package com.example.Controller;

import com.example.pojo.JobDTO;
import com.example.service.JobService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController("/job")
public class JobController {
    @Autowired
    private JobService jobService;

    @GetMapping("/getAllJobs")
    public Object getAllJobs(){
        return jobService.getAllJobs();
    }

    @PostMapping("/pauseJob")
    public Object pauseJob(@Validated @RequestBody JobDTO jobDTO){
        return jobService.pauseJob(jobDTO);
    }

    @PostMapping("/pauseAllJobs")
    public Object pauseAllJobs(){
        return jobService.pauseAllJobs();
    }

    @PostMapping("/resumeJob")
    public Object resumeJob(@Validated @RequestBody JobDTO jobDTO){
        return jobService.resumeJob(jobDTO);
    }

    @PostMapping("/resumeAllJobs")
    public Object resumeAllJobs(){
        return jobService.resumeAllJobs();
    }

    @PostMapping("/startJob")
    public Object startJob(@Validated @RequestBody JobDTO jobDTO){
        return jobService.startJob(jobDTO);
    }

    @PostMapping("/deleteJob")
    public Object deleteJob(@Validated @RequestBody JobDTO jobDTO){
        return jobService.deleteJob(jobDTO);
    }


    @PostMapping("/addJob")
    public Object addJob(@Validated @RequestBody JobDTO jobDTO){
        return jobService.addJob(jobDTO);
    }

    @PostMapping("/modifyJobTrigger")
    public Object modifyJobTrigger(@Validated @RequestBody JobDTO jobDTO){
        return jobService.modifyJobTrigger(jobDTO);
    }

}
